package com.example.mybatisplus.web.controller;

import com.example.mybatisplus.mapper.HotelMapper;
import com.example.mybatisplus.model.domain.HOrder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.mybatisplus.common.JsonResponse;
import com.example.mybatisplus.service.HotelService;
import com.example.mybatisplus.model.domain.Hotel;

import java.util.List;


/**
 * 前端控制器
 *
 * @author yfy
 * @version v1.0
 * @since 2021-12-30
 */
@RestController
@RequestMapping("/api/hotel")
public class HotelController {

    private final Logger logger = LoggerFactory.getLogger(HotelController.class);

    @Autowired
    private HotelService hotelService;

    @Autowired
    private HotelMapper hotelMapper;

    @GetMapping("/show")
    public JsonResponse showPoint() {
        List<Hotel> hotels = hotelService.list();
        return JsonResponse.success(hotels);
    }

    @GetMapping("/selectByName")
    public JsonResponse selectByName(String name) {
        List<Hotel> hotels = hotelMapper.selectByName(name);
        return JsonResponse.success(hotels);
    }

    @GetMapping("/one")
    public Hotel one(Long id) {
        Hotel hotel = hotelService.getById(id);
        return hotel;
    }
}

